package com.springboot.test.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnClass({Demo.class})
@EnableConfigurationProperties(DemoProperties.class)
public class DemoAutoConfig {

    @Bean
    public Demo getDemo (DemoProperties  demoProperties){
        Demo demo = new Demo();
        demo.setName(demoProperties.getName());
        demo.setAge(demoProperties.getAge());
        demo.setEmail(demoProperties.getEmail());
        return demo;
    }
}
